package com.example.dbsample.model.enums;

import org.apache.commons.lang3.StringUtils;

/**
 * 该类实现根据Apollo动态 增加枚举值，枚举值不止代码中的这些
 */
public enum PlatformEnum {
    PLATFORM_SH("shanghai", "上海"),
    PLATFORM_SZ("shenzhen", "深圳");

    private String code;
    private String desc;

    PlatformEnum() {
    }

    PlatformEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public static PlatformEnum getEnumByCode(String code) {
        for(PlatformEnum e : PlatformEnum.values()) {
            if(StringUtils.equals(code, e.getCode())) {
                return e;
            }
        }
        return null;
    }
}
